<!DOCTYPE html>

<html lang="zh-cmn-Hans">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
    <link rel="stylesheet" href="../../static/assets/css/zpui.css" />
    <link rel="stylesheet" href="../../static/assets/css/all.css" />
    <link rel="stylesheet" href="../../static/mobile/default/css/payment.css" />
    <link rel="stylesheet" href="../../static/mobile/default/css/userData.css" />
    <link rel="stylesheet" href="../../static/mobile/default/css/layout.css" />
    <script src="../../static/assets/js/page.js"></script>

    <title> 补货 </title>
</head>

<body>
    <div class="page">
        <div class="page-hd">
            <div class="header bor-1px-b">
                <div class="header-left">
                    <a href="javascript:history.go(-1)" class="left-arrow"></a>
                </div>
                <div class="header-title">补货</div>
                <div class="header-right">
                    <a href="#"></a>
                </div>
            </div>
        </div>

        <div class="page-bd">
            <!-- 页面内容-->
            <div class="weui-cells card-box">
                <div class="weui-cell">
                    <div class="weui-cell__hd mr10">
                        <img src="/upload/gimg/2020/09/5f68609dd8f41_thumb.jpg" class="img140">
                    </div>
                    <div class="weui-cell__bd ">
                        <div class="fs28 ellipsisLn1">茅源庆典酒（云仓6瓶/箱）</div>
                        <div class="fs26 mt30">进货价：380</div>
                    </div>
                </div>
            </div>
            <div class="weui-cells card-box">
                <div class="weui-cell">
                    <div class="weui-cell__bd">
                        <div>
                            <span class="fs28 fw600">补货数量</span>
                        </div>
                        <div class="tx_input mt20">
                            <input class="weui-input" id="number" type="number" placeholder="请填写补货数量">
                        </div>
                        <!--<div class="mt20">
                        <span class="fs28 fw600">支付方式</span>
                    </div>
                    <div class="mt20 paybox">
                        <input  data-value="1" class="paybtn paycheck" value="微信支付">
                        <input  data-value="2" class="paybtn" value="余额支付">
                    </div>-->
                    </div>
                </div>
            </div>
            <div class="weui-btn-area">
                <a href="javascript:;" class="weui-btn weui-btn_primary replenishment">确定</a>
            </div>
        </div>
        <link rel="stylesheet" href="../../static/mobile/default/css/payment.css?v=1" />
<link rel="stylesheet" href="../../static/mobile/default/css/userData.css" />
<link rel="stylesheet" href="../../static/mobile/default/css/wallet.css" />
<style>
    .text{
        padding: .2rem;
    }
    .account{
        background-color: #fff;
    }
    .oblock{
        margin: 0 .2rem .08rem;
        border-radius: .066667rem;
    }
    .oblock .type{
        display: flex;
        align-items: center;
        margin-bottom: .133333rem;
    }
    .oblock{
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        padding: .2rem 0;
        background-color: #ff00000a;
    }
    .oblock .type img{
        width: .266667rem;
        height: .266667rem;
        margin-right: .053333rem;
    }
    .weixinCode{
        width: 1.466667rem;
        height: 1.466667rem;
    }
    .oblock p{
        margin: .1rem 0 .2rem;
    }
    .chongzhi .button {
        width: 4.466667rem;
        margin: 0.266667rem 0.2rem;
        height: 0.533333rem;
        display: -webkit-box;
        display: -webkit-flex;
        display: flex;
        -webkit-box-pack: center;
        -webkit-justify-content: center;
        justify-content: center;
        -webkit-box-align: center;
        -webkit-align-items: center;
        align-items: center;
    }
    .offlinepage{
        position:absolute;
        top: 0;
        left: 100%;
        width: 100%;
        height: 100%;
        overflow: auto;
        z-index: 999;
    }

</style>
<div class="offlinepage">
    <div class="page-hd">
        <div class="header bor-1px-b">
            <div class="header-left">
                <a class="left-arrow" onClick="hideoff()"></a>
            </div>
            <div class="header-title">上传凭证</div>
            <div class="header-right">
                <a href=''></a>
            </div>
        </div>
    </div>
    <div class="page-bd chongzhi">
        <!-- 页面内容-->
        <div class="account">
            <div class="text fs28">您需要转款至以下任一账户</div>
            <div class="oblock">
                <div class="type"><img src="../../static/mobile/default/images/weixinPay.png" alt=""><span class="fs28">微信收款码</span></div>
                <img src="" alt="" class="weixinCode">
            </div>
            <div class="oblock">
                <div class="type"><img src="../../static/mobile/default/images/aliPay.png" alt=""><span class="fs28">支付宝收款码</span></div>
                <img src="" alt="" class="weixinCode">
            </div>
            <div class="oblock">
                <div class="type"><img src="../../static/mobile/default/images/offlinePay.png" alt=""><span class="fs28">银行账户</span></div>
                <p class="fs32 fw_b color_3"></p>
                <span class="fs28 color_3"></span>
                <div class="fs28 color_3"><span></span></div>
            </div>
        </div>
         <div class="uploading" style="display: block; ">
                <div class="title fs32 fw_b color_3">上传收款二维码（必须)</div>
                <div class="uploadBox" >

                    <div class="Box" id="upload_qrcode_box">
                        <img src="../../static/mobile/default/images/addImg.png" alt="" class="imgBox">
                        <input type="file" class="uploadInput" >
                    </div>
                    <div></div>
                </div>
            </div>
        <!-- <div class="uploading" style="display: block; " >
            <div class="title fs28 fw_b color_3">上传打款凭证（必须)</div>
            <div class="uploadBox" style="flex-wrap: wrap;overflow: initial;">
                <ul class="weui-uploader__files uploaderFiles" id="uploaderFiles1">
                </ul>
                <form enctype="multipart/form-data" id="uploadForma">
                <div class="Box">
                    <img src="../../static/mobile/default/images/addImg.png" alt="" class="imgBox">
                        <input id="uploadInput" onchange="uploadFile(this,event)" class="weui-uploader__input"
                               type="file"
                               accept="image/*" multiple="">
                </div>
                </form>
                <div ></div>
            </div>
        </div> -->
        <div class="button fs32 fw_b color_w BGcolor_r buttBox payBtn"><span>提交</span></div>
    </div>
    <!-- 弹出提示 -->
    <div class="layout" style="display: none">
        <div class="layoutBG"></div>
        <div class="layoutBox">
            <div class="text fs30 color_3 bor_b">
                您还未上传支付凭证！
            </div>
            <!-- 单按钮 -->
            <div class="button fs32 color_9">
                知道了
            </div>
        </div>
    </div>
</div>
<script>

    var fd = new FormData();
    var imgNum = 0;

    //选择上传图片
    function uploadFile(_this,e){

        var formData = new FormData($("#uploadForma")[0])  //创建一个forData
        formData.append('file', $('#uploadInput')[0].files[0]) //把file添加进去  name命名为img
        $.ajax({
            url: '/member/api._passport/proposal_img.html',
            data: formData,
            type: "POST",
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            success: function (data) {

                if (data.code == 1) {
                    _alert(data.msg);
                    return false;

                }
                imgNum++;
                fd.append("imgfile["+imgNum+"]", data.url);
                $('#uploaderFiles1').before('<div class="Box"><img src="'+ data.url+'" alt="" class="imgBox payimg"><img src="../../static/mobile/default/images/closeImg.png" alt="" data-imgnum="'+imgNum+'" class="closeImg"></div>');
            },
            error: function () {
                //失败
            }

        });

    }
    function hideoff(){
        $('.offlinepage').css('left','100%');
        offlineChoose = false;
    }
</script>
<script src="../../static/mobile/default/js/uploadsimage.js?v=1"></script>
<script>
    //处理点击改变的调用函数-做IOS兼容
    $(_listenSelector).click(function(){
            var that = $(this);
     
            _uplocalfunction=function(base64Img){
                   fd.append("qrcodefile", base64Img);
                   $(that).parent().before('<div class="Box"><img src="'+base64Img+'" alt="" class="imgBox payimg"><img src="../../static/mobile/default/images/closeImg.png" alt="" class="closeImg" data-type="one"></div>');
                   $('#upload_qrcode_box').css('visibility','hidden');
                   //$(_listenSelector).hide();
            } 
           
    })
</script>
        <div class="model">
            <div class="modelContent">
                <div class="closeBox"><img src="../../static/mobile/default/images/close_icon.png" alt=""></div>
                <div class="title fs36 color_3 fw_b">请选择支付方式</div>
                <div class="cantre pay" id="payListBox">

                    <p class="get_list_tip">加载中...</p>

                </div>
                <div class="buttBox">
                    <span class="fs32 fw_b color_w BGcolor_r payBtn">确认支付</span>
                </div>
            </div>
        </div>
    </div>
    
    <script type="text/html" id="payListTpl">
        {{each data as item index}}
        <div class="block">
            <label for="{{item.pay_code}}" style="width: 100%;">
            <div class="payType">
                <img src="../../static/mobile/default/images/{{item.img}}" alt="">
                <div>
                    <span class="fs30 color_3">{{item.pay_name}}</span>
                    {{if item.pay_code == 'balance'}}
                    <span class="fs26 color_r">(￥{{balance_money}})</span>
                    {{/if}}
                </div>
            </div>
        </label>
            <label for="{{item.pay_code}}">
            <div class="iconBox">
                <input type="radio" class="check" name="pay_id" value="{{item.pay_id}}" data-pay_code="{{item.pay_code}}" id="{{item.pay_code}}" >
                <i class="icon_checked"></i>
            </div>
        </label>
        </div>
        {{/each}}
    </script>
    
    <style>
        .paybtn {
            width: 60px;
        }
    </style>
    <script src="../../static/js/art-template.js"></script>
    <script src="../../static/assets/js/lib/jquery-2.1.4.js"></script>
    <script src="../../static/assets/js/jquery-weui.min.js"></script>
    <script src="../../static/assets/js/lib/fastclick.js"></script>
    <script>
        $(function() {
            FastClick.attach(document.body);
        });
    </script>
    <script>
        var offlineChoose = false;
        $(".paybtn").on('click', function() {
            $(this).addClass('paycheck').siblings().removeClass('paycheck');
        });
        $('.replenishment').click(function(res) {
            if(!$('#number').val() || $('#number').val() == 0){
                $.alert('数量必须填写.');
                return;
            }
            if($('#number').val() % 1 != 0){
                $.alert('数量必为整数');
                return;
            }
            $.ajax({
                type: 'POST',
                url: '/publics/api.pay/getlist.html',
                success: function(res) {
                    if (res.code == 0) {
                        _alert(res.errmsg);
                        return false;
                    }
                    $('#payListBox').html(template('payListTpl', res));
                    $('.model').show();
                }
            })
        })
        $('.closeBox').on('click', function() {
            $('.model').hide();
        });
        $('.payBtn').on('click', function() {
            $('.model').hide();
            var obj = $('input:radio[name="pay_id"]:checked');
            if (typeof(obj.val()) == 'undefined') {
                _alert('请选择支付方式.');
                return false;
            }
            var pay_code = obj.data("pay_code");

            //线下支付
            if (obj.val() == 3) {
                //没弹窗
                if (offlineChoose == false) {
                    offlineChoose = true;
                    //弹一下窗
                    $('.offlinepage').css('left', 0);
                    return false;
                }
                //上传图片判断
                var payimg = $(".payimg").attr('src');
                if (typeof(payimg) == 'undefined' || payimg == '') {
                    _alert('请上传支付凭证.');
                    return false;
                }

                var arr = new Object();
                //arr.order_id = 0;
                arr.pay_code = pay_code;
                arr.payimg = payimg;
                $.ajax({
                    type: 'POST',
                    url: '/shop/api.flow/tooffline.html',
                    data: arr,
                    success: function(res) {
                        if (res.code == 0) {
                            $(this).removeAttr('disabled');
                            _alert(res.errmsg);
                            return false;
                        }
                    }
                })
            }
            let data = {
                'goods_id': "124",
                'count': $('.weui-input').val(),
                'pay_code': pay_code,
            };
            $.ajax({
                    type: 'POST',
                    url: '/publics/payment/replenish.html',
                    data: data,
                    success: function(res) {
                        $.alert(res.errmsg, function() {
                            window.location.href = res.url;
                        });
                        if (res.code == 0) {
                            return false;
                        }
                    }
                })
                //window.location.href = '/publics/payment/replenish/?pay_code='+pay_code+'&goods_id='+goods_id+'&count='+count;
        });
    </script>
</body>

</html>